package com.five.controller.backstage;


import com.five.dao.backstage.DeptDao;
import com.five.entity.backstage.DEPT;
import com.five.util.LayTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName DeptController
 * @Description TODO
 * @Author yuanshuaiqiang
 * @Date 2020/11/25 17:06
 */
@RestController
@RequestMapping("dept")
public class DeptController {

    @Autowired
    private DeptDao deptDao;
    @RequestMapping("queryAll")
    public LayTable queryAll(Integer page, Integer limit, DEPT dept){

        int i=deptDao.getCount(dept);
        List<Map> maps = deptDao.queryAll(page,limit,dept);
        //传入前台的数据为laytable
        LayTable layTable = new LayTable(i,maps);
        return layTable;
    }

    @RequestMapping("del")
    public int del(DEPT dept){
        int i=deptDao.del(dept);
        if (i>0){
            return i;
        }
        return 1;
    }

    @RequestMapping("upd")
    public int upd(DEPT dept){

        int i=deptDao.upd(dept);
       // System.out.println(i);
        if (i>0){
            return i;
        }
        return -1;
    }

    @RequestMapping("add")
    public int add(DEPT dept){

        int i= deptDao.add(dept);
        if (i>0){
           return i;
        }
        return -1;
    }


    @RequestMapping("bad")
    public int updata(Integer id){
        int i=deptDao.bad(id);
        System.out.println(id+"=="+i);

        if (i>0){
            return i;
        }
        return -1;
    }
    @RequestMapping("good")
    public int updatagood(Integer id){

        int i=deptDao.good(id);
        if (i>0){
            return i;
        }
        return -1;
    }

}
